<?php
/**
 * <https://y.st./>
 * Copyright © 2019 Alex Yst <mailto:copyright@y.st>
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <https://www.gnu.org./licenses/>.
**/

$xhtml = array(
	'<{title}>' => 'Hardware',
	'<{subtitle}>' => 'Written in <span title="Operating Systems 2">CS 3307</span> by <a href="https://y.st./">Alexand(er|ra) Yst</a>, finalised and <a href="https://y.st./en/coursework/CS3307/Hardware.xhtml">archived</a> on 2019-05-08',
	'<{copyright year}>' => '2019',
	'takedown' => '2017-11-01',
	'<{body}>' => <<<END
<div class="APA_title_page">
	<p>
		Hardware<br/>
		Alexand(er|ra) Yst<br/>
		<span title="Operating Systems 2">CS 3307</span>
	</p>
</div>
<h2><kbd>lsblk</kbd></h2>
<img src="/img/CC_BY-SA_4.0/y.st./coursework/CS3307/lsblk.png" alt="lsblk" class="framed-centred-image" width="661" height="411"/>
<p>
	<code>lsblk</code> shows you your block devices (hard drives, $a[USB] drives, et cetera) and the partitions they contain (Broz &amp; Zak, 2013).
	The first $[SCSI] device on Linux is usually called <code>sda</code>, with the second $a[SCSI] device being called <code>sdb</code>, the third bing <code>sdc</code>, and so on.
	While Windows runs out of drive letters after <code>z:\\\\</code>, Linux really doesn&apos;t. After <code>sdz</code>, you just continue on to <code>sdaa</code> and use longer drive names (Cobbaut, 2015).
	$a[ATA] (an older standard) devices are also labelled as <code>hda</code>, <code>hdb</code>, et cetera instead of <code>sda</code>, <code>sdb</code>, et cetera (Cobbaut, 2015).
	From this command, we see I have only one disk, an $a[SCSI] device, called <code>sda</code>.
	You can see it has three main partitions: a boot partition, a one-kilobyte partition (I actually don&apos;t know what that partition is for; the $a[OS] installer put that there), and my main partition.
	The main partition is entirely filled with an encrypted block, and that encrypted block contains my main filesystem and my swap partition.
	Because my filesystem is encrypted, if my laptop were stolen, the thief would be unable to read my files without my password, though they could still erase the contents of the drive and use it for something else.
</p>
<h2><kbd>cat /sys/block/sda/queue/scheduler</kbd></h2>
<img src="/img/CC_BY-SA_4.0/y.st./coursework/CS3307/cat_~sys~block~sda~queue~scheduler.png" alt="cat /sys/block/sda/queue/scheduler" class="framed-centred-image" width="661" height="411"/>
<p>
	As indicated by the square brackets, the scheduler for my only hard drive is set to use $a[CFQ].
</p>
<h2><kbd>find / -name fstab 2&gt; /dev/null</kbd></h2>
<img src="/img/CC_BY-SA_4.0/y.st./coursework/CS3307/find_~_-name_fstab_2~_~dev~null.png" alt="find / -name fstab 2&gt; /dev/null" class="framed-centred-image" width="661" height="411"/>
<p>
	The command I used here begs a bit of explanation.
	In theory, simply <code>find / -name fstab</code> should have worked.
	<code>/</code> tells <code>find</code> to start at the root of the file system, while <code>-name fstab</code> tells it that the file&apos;s name should be <code>fstab</code>.
	So what&apos;s the problem?
	Well, <code>find</code> complains every time it encounters a directory you don&apos;t have permission to read.
	It outputs countless error messages, one for each such directory.
	There are so many system directories that regular users aren&apos;t allowed to access for security reasons that the error messages drown out the list of actual files found.
	Seriously, when I tried just <kbd>find / -name fstab</kbd>, the actual files found were pushed outside the range of the output backlog, and I wasn&apos;t able to see those files at all.
	While the errors were showing up in command line window though, they weren&apos;t technically being sent to standard output, but rather standard error.
	The <code>2&gt;</code> operator allows standard error to be redirected to somewhere other than the command line window, effectively filtering it out, and <code>/dev/null</code> is the null device, an abstraction that accepts input sent to it but simply discards it.
	Putting that all together, <kbd>find / -name fstab 2&gt; /dev/null</kbd> searches the entire file tree for files named <code>fstab</code>, but doesn&apos;t show any errors it encounters - such as but not limited to permission errors - as it does so.
</p>
<h2><kbd>df</kbd></h2>
<img src="/img/CC_BY-SA_4.0/y.st./coursework/CS3307/df.png" alt="df" class="framed-centred-image" width="661" height="411"/>
<p>
	The <kbd>df</kbd> command shows you your disk space usage (Granlund, MacKenzie, &amp; Eggert, 2018).
	Most of these are filesystems used by the $a[OS].
	However, my <code>/</code> partition is approaching full, at 85%.
	I didn&apos;t realise I had so much on my computer.
	It might be time for me to clean up my files a bit.
	There&apos;s probably a lot I don&apos;t really need any more, but forgot to delete when I was done with it.
</p>
<h2><kbd>du -h</kbd></h2>
<img src="/img/CC_BY-SA_4.0/y.st./coursework/CS3307/du_-h.png" alt="du -h" class="framed-centred-image" width="661" height="411"/>
<p>
	The <code>du</code> command shows your estimated disk usage for each directory in your current working directory, while the <code>-h</code> flag tells it to format the sizes in a more-readable way (Granlund, MacKenzie, &amp; Eggert, 2010).
</p>
<p>
	The output is a bit long, especially as it checks directories recursively, as seen in the screenshot.
	At the end of the output, you see the full size of the current directory, my home directory, as well as the sizes of my <code>~/bin</code> directory and some Firefox-related directories.
	In the Firefox directories, you can see I have an alternate profile with JavaScript disabled that I use for my university work.
	Or more-specifically, I use that to access the school&apos;s website.
	This is because a bug in the school&apos;s JavaScript causes the website to eat my coursework, and the only way I&apos;ve found to get it to stop is to disable JavaScript entirely.
	I&apos;ve talked to university support about the bug, but they&apos;ve told me that they have no intention to fix it, so disabling JavaScript at the school is just something I have to do to avoid losing the fruits of my labours.
</p>
<h2><kbd>lspci -nn</kbd></h2>
<img src="/img/CC_BY-SA_4.0/y.st./coursework/CS3307/lspci_-nn.png" alt="lspci -nn" class="framed-centred-image" width="661" height="411"/>
<p>
	<code>lspci</code> lists all the $a[PCI] devices attached to the machine.
	The <code>-nn</code> flag causes it to show the names and device codes of each device (Mares, n.d.).
	Above, you can see the end of my list of my $a[PCI] devices, which includes my Wi-Fi adapter, some $a[USB] ports, and other things.
</p>
<h2>Conclusion</h2>
<p>
	As we can see, there&apos;s a lot of information we can get about our hardware and filesystems from the computer itself.
	We don&apos;t have to open up the computer to see what $a[PCI] devices are available, for example.
	All we have to do is ask the computer!
	We can also see how drives are partitioned and how much space is being used on the drives; something we&apos;d never be able to know by opening up the computer and looking at the parts.
</p>
<div class="APA_references">
	<h2>References:</h2>
	<p>
		Broz, M., &amp; Zak, K. (2013, February). <a href="http://man7.org/linux/man-pages/man8/lsblk.8.html">lsblk(8) - Linux manual page</a>. Retrieved from <code>http://man7.org/linux/man-pages/man8/lsblk.8.html</code>
	</p>
	<p>
		Cobbaut, P. (2015, May 24). <a href="http://linux-training.be/sysadmin/ch04.html">Chapter 4. disk devices</a>. Retrieved from <code>http://linux-training.be/sysadmin/ch04.html</code>
	</p>
	<p>
		Granlund, T., MacKenzie, D., &amp; Eggert, P. (2010, September). <a href="http://linuxcommand.org/lc3_man_pages/du1.html">du man page</a>. Retrieved from <code>http://linuxcommand.org/lc3_man_pages/du1.html</code>
	</p>
	<p>
		Granlund, T., MacKenzie, D., &amp; Eggert, P. (2018, July). <a href="http://man7.org/linux/man-pages/man1/df.1.html">df(1) - Linux manual page</a>. Retrieved from <code>http://man7.org/linux/man-pages/man1/df.1.html</code>
	</p>
	<p>
		Mares, M. (n.d.). <a href="https://linux.die.net/man/8/lspci">lspci(8): all PCI devices - Linux man page</a>. Retrieved from <code>https://linux.die.net/man/8/lspci</code>
	</p>
</div>
END
);
